package main

import (
	"fmt"
	"sync"
	"time"
)

type MotherEarth struct {
}

var earth *MotherEarth

var onceEarth sync.Once

func getEarth() *MotherEarth {
	onceEarth.Do(func() {
		earth = &MotherEarth{}
		fmt.Println("实例化一个地球")
	})
	return earth
}

func main() {
	for i := 0; i < 100; i++ {
		go func() {
			_ = getEarth()
		}()
	}
	time.Sleep(time.Second)
}
